<template>
  <view class="tabbar">
    <view class="tabbar-item" v-for="(item,index) in list" :key="index" @click="changeTab(index)">
      <image class="img" :src="item.selectedIconPath" v-if="current == index"></image>
      <image class="img" :src="item.iconPath" v-else></image>
      <view class="text active" v-if="current == index">{{item.text}}</view>
      <view class="text" v-else>{{item.text}}</view>
    </view>
  </view>
</template>

<script>
  export default {
    name: "tabbar",
    props: {
      current: Number
    },
    created() {
      uni.hideTabBar()
    },
    data() {
      return {
        list: [{
            selectedIconPath: "../../static/img/Home_1.png",
            iconPath: "../../static/img/Home.png",
            text: '商单',
            pagePath: "pages/home/home"
          },
          {
            selectedIconPath: "../../static/img/star_1.png",
            iconPath: "../../static/img/star.png",
            text: '达人',
            pagePath: "pages/people/people"
          },
          {
            selectedIconPath: "../../static/img/Person_1.png",
            iconPath: "../../static/img/Person.png",
            text: '我的',
            pagePath: "pages/my/my"
          }
        ],
      }
    },
    methods: {
      changeTab(e) {
        uni.switchTab({
          url: '/' + this.list[e].pagePath,
        })
      }
    }
  }
</script>

<style scoped>
  .tabbar {
    position: fixed;
    left: 0;
    bottom: 0;
    z-index: 99;
    width: 750rpx;
    height: 166rpx;
    background: #FFFFFF;
    box-shadow: 0rpx -1rpx 0rpx 0rpx rgba(255,255,255,0.08);
    border-radius: 28rpx 28rpx 0rpx 0rpx;
    opacity: 1;
    display: flex;
    justify-content: space-around;
  },
  .tabbar-item {
    margin-top: 12rpx;
    padding: 0 40rpx;
    text-align: center;
  }

  .img {
    height: 48rpx;
    width: 48rpx;
  }

  .text {
    font-size: 20rpx;
    font-family: PingFang SC-Regular, PingFang SC;
    font-weight: 400;
    color: #000;
    line-height: 23rpx;
  }

  .text.active {
    color: #000;
  }
</style>